/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2025/4/26
 * Time: 23:37
 */

#ifndef SPRITE_H
#define SPRITE_H
#include "../core/ObjectAffiliate.h"
#include <SDL3/SDL_render.h>
#include <string>

struct Texture {
    SDL_Texture * texture {nullptr};
    SDL_FRect     src_rect {0, 0, 0, 0};
    float         angle {0};
    bool          is_flip {false};

    Texture() = default;
    explicit Texture(const std::string & file_path);
};

class Sprite : public ObjectAffiliate
{

public:
    static Sprite * AddSpriteChild(ObjectScreen * _parent, const std::string & _file_path, float _scale = 1.0f, Anchor _anchor = Anchor::CENTER);

    Sprite() = default;
    void Render() override;

    void SetFlip(bool _flip) { texture_.is_flip = _flip; };

    void SetAngle(float _angle) { texture_.angle = _angle; };

    void SetFinish(bool _finish) { is_finish_ = _finish; };
    bool IsFinish() { return is_finish_; };

    Texture      GetTexture() const { return texture_; }
    virtual void SetTexture(const Texture & texture);

protected:
    Texture texture_;
    bool    is_finish_ {false};
};

#endif//SPRITE_H
